﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

namespace Mvc4
{
    public class RouteConfig
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(
                name: "SiteView",
                url: "{site}",
                defaults: new { controller = "HomeSite", action = "Index" },
                constraints: new { site = new SubdomainConstraint() } );

            routes.MapRoute(
                name: "Search",
                url: "{site}/Search",
                defaults: new { controller = "HomeSite", action = "Search" },
                constraints: new { site = new SubdomainConstraint() });

            routes.MapRoute(
                name: "NewGood",
                url: "{site}/NewGood",
                defaults: new { controller = "Good", action = "Create" },
                constraints: new { site = new SubdomainConstraint() });

            routes.MapRoute(
                name: "GoodEdit",
                url: "{site}/Edit/{id}",
                defaults: new { controller = "Good", action = "Edit", id = "" },
                constraints: new { site = new SubdomainConstraint() } );

            routes.MapRoute(
                name: "NewAttribute",
                url: "{site}/NewAttribute/{id}",
                defaults: new { controller = "Attribute", action = "Create", id = "" },
                constraints: new { site = new SubdomainConstraint() });

            routes.MapRoute(
                name: "GoodView",
                url: "{site}/View/{id}",
                defaults: new { controller = "Good", action = "Details", id = "" },
                constraints: new { site = new SubdomainConstraint() });

            routes.MapRoute(
                name: "AddLike",
                url: "{site}/AddLike",
                defaults: new { controller = "Good", action = "AddLike" },
                constraints: new { site = new SubdomainConstraint() });

            routes.MapRoute(
                name: "RemoveLike",
                url: "{site}/RemoveLike",
                defaults: new { controller = "Good", action = "RemoveLike" },
                constraints: new { site = new SubdomainConstraint() });

            routes.MapRoute(
                name: "AddInap",
                url: "{site}/AddInap",
                defaults: new { controller = "Good", action = "AddInap" },
                constraints: new { site = new SubdomainConstraint() });

            routes.MapRoute(
                name: "AddContent",
                url: "{site}/AddContent",
                defaults: new { controller = "Good", action = "AddContent" },
                constraints: new { site = new SubdomainConstraint() });

            routes.MapRoute(
                name: "MyStuff",
                url: "{site}/MyStuff",
                defaults: new { controller = "Good", action = "Index" },
                constraints: new { site = new SubdomainConstraint() });

            routes.MapRoute(
                name: "MyWishList",
                url: "{site}/MyWishList",
                defaults: new { controller = "WishLists", action = "Wishes" },
                constraints: new { site = new SubdomainConstraint() });

            routes.MapRoute(
                name: "EditMyWishList",
                url: "{site}/MyWishList/Edit",
                defaults: new { controller = "WishLists", action = "MyWishList" },
                constraints: new { site = new SubdomainConstraint() });

            routes.MapRoute(
                name: "Pay",
                url: "{site}/Pay",
                defaults: new { controller = "Pay", action = "Pay" },
                constraints: new { site = new SubdomainConstraint() });

            routes.MapRoute(
                name: "AcceptedPay",
                url: "{site}/AcceptedPay",
                defaults: new { controller = "Pay", action = "AcceptedPay" },
                constraints: new { site = new SubdomainConstraint() });

            routes.MapRoute(
                name: "FriendSites",
                url: "FriendSites",
                defaults: new { controller = "Grupo1Listados", action = "ListarInstancias" });

            routes.MapRoute(
                name: "FriendGoods",
                url: "FriendSites/{id}",
                defaults: new { controller = "Grupo1Listados", action = "ListarBienes", id="" });

            routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional },
                constraints: new
                {
                    controller = new ControllerConstraint()
                });

            routes.MapRoute(
                "Error2",
                "{*url}",
                new { controller = "Home", action = "Error" }
            );
        }
    }
}